package problems.contest;

/**
 * @author dubulingbo, 2023/9/3 10:23.
 */
public class WC361 {
    /**
     * T1|
     */
    public int countSymmetricIntegers(int low, int high) {
        int cnt = 0;
        for (int i = low; i <= high; ++i) {
            if (((i > 10 && i < 100) || (i > 1000 && i < 10000)) && judge(i)) {
                ++cnt;
            }
        }
        return cnt;
    }

    private boolean judge(int num) {
        String s = String.valueOf(num);
        int n = s.length();
        int ls = 0, hs = 0;
        for (int i = 0; i < n / 2; ++i) {
            hs += (s.charAt(i) - '0');
            ls += (s.charAt(n - 1 - i) - '0');
        }
        return hs == ls;
    }
}
